package com.xxxx.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxxx.server.mapper.IvaccineMapper;
import com.xxxx.server.pojo.Admin;
import com.xxxx.server.pojo.Ivaccine;
import com.xxxx.server.pojo.RespPageBean;
import com.xxxx.server.pojo.Svaccine;
import com.xxxx.server.mapper.SvaccineMapper;
import com.xxxx.server.service.ISvaccineService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 学生疫苗登记表 服务实现类
 * </p>
 *
 * @author zhoubin
 * @since 2022-06-04
 */
@Service
public class SvaccineServiceImpl extends ServiceImpl<SvaccineMapper, Svaccine> implements ISvaccineService {

    @Autowired
    private SvaccineMapper svaccineMapper;
    @Override
    public List<Svaccine> getByColegeIdSvaccine() {
        return svaccineMapper.getByColegeIdSvaccine(((Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getCollegeid());
    }

    @Override
    public RespPageBean getSvaccineByPage(Integer currentPage, Integer size, Svaccine svaccine, String[] beginDateScope, int type, String collegeName, int collegeid,int classid,String classname) {
        //开启分页
        Page<Svaccine> page = new Page<>(currentPage,size);
        IPage<Svaccine> svaccineByPage = svaccineMapper.getSnvaccineByPage(page, svaccine, beginDateScope,type,collegeName,collegeid,classid,classname);
        RespPageBean respPageBean = new RespPageBean(svaccineByPage.getTotal(), svaccineByPage.getRecords());
        return respPageBean;
    }

    @Override
    public List<Svaccine> getSnvaccineSeachList(Svaccine svaccine, String[] beginDateScope, int type, String collegename, int collegeid,int classid,String classname) {
        return svaccineMapper.getSnvaccineSeachList(svaccine, beginDateScope,type,collegename,collegeid,classid,classname);
    }

}
